package chapter04;

/**
 * ClassName: ForWhileTest2
 * Package: capter03
 * Description:
 * 打印一个菱形。
 *        *
 *       * * *
 *     * * * * *
 *   * * * * * * *
 * * * * * * * * * *
 *   * * * * * * *
 *     * * * * *
 *       * * *
 *         *
 * @Author 安思宇
 * @Create 2024/11/26 13:58
 */
public class ForWhileTest2 {
    public static void main(String[] args) {
        //for嵌套循环，外层控制行数，内层控制列数
        //上半部分
        for (int i = 1; i <= 5; i++) {
            for (int m = 1; m <=10-2*i; m++) {
                System.out.print(" ");
            }
            for (int n = 1; n <=2*i-1; n++) {
                System.out.print("* ");
            }
            System.out.println();
        }
        for (int i = 1; i <= 4; i++) {
            //-
            for (int j = 1; j <= 2 * i; j++) {
                System.out.print(" ");
            }

            //*
            for (int k = 1; k <= 9 - 2 * i; k++) {
                System.out.print("* ");
            }
            System.out.println();
        }
    }
}